package com.bg.sparkproject.pattern.template;

/**
 * @Auther: zhengshunzhi
 * @Date: 2019/1/4 16:41
 * @Description: 开车模板抽象类
 */
public abstract class DriveTemplate {
    public final void drive() {
        openDoor();
        startEngine();
        gear();
        go();
        brake();
        stop();
    }

    protected abstract void openDoor();

    //模板代码不让子类重写，加final修饰
    protected final void startEngine() {
        System.out.println("engine started !");
    }

    protected abstract void gear();

    protected final void go() {
        System.out.println("running...");
    }

    protected abstract void brake();

    protected final void stop() {
        System.out.println("stopped !");
    }
}

